﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Fastidious.Web
{
	/// <summary>
	/// Sets a far off cache date header 
	/// to all content except actual pages
	/// </summary>
	public class CacheHeadersModule : IHttpModule
	{
		#region IHttpModule Members

		public void Dispose()
		{
			
		}

		public void Init(HttpApplication context)
		{
			context.PreSendRequestHeaders += (o, e) =>
			{
				var type = HttpContext.Current.Response.ContentType;
				if (type != "text/html")
				{
					HttpContext.Current.Response.Headers["Expires"] = "Sun, 17 Jan 2038 19:14:07";
					//HttpContext.Current.Response.Headers["Cache-Control"] = "max-age=2000000000";
				}
			};
		}
		#endregion
	}
}